package luogu;

import java.util.Scanner;

public class Main21 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String[] inputNumbers = sc.nextLine().split(" ");
        int [] arr = new int[n];
        for (int i = 0; i < n ; i++) {
            arr[i] = Integer.parseInt(inputNumbers[i]);
        }
        StringBuilder sb = new StringBuilder();
        for (int num : arr) {
            if (isPrime(num)){
                sb.append(num).append(" ");
            }
        }
        if (sb.length() > 0){
            sb.setLength(sb.length()-1);    //移除最后一个空格
        }
        System.out.println(sb);
    }

    private static boolean isPrime(int number){
        if (number<=1){
            return false;
        }
        if (number%2==0){
            return false;
        }
        if (number==2){
            return true;
        }
        for (int i = 3; i * i<=number ; i+=2) {
            if (number%i==0){
                return false;
            }
        }
        return true;
    }
}
